# write_byte_data.py
#
# Sample code to write a byte to a binary file.
# Only gives an example of writing a number that fits into a byte.
#
# Note: You should think how you would write a number > 255.

import array

filename = "test.dat"
print "Write data to a binary file", filename

# Open file with "wb": w-write, b-binary
file = open(filename, "wb")
# Create a byte array
data = array.array('B')
# Write one byte (36 < 2^8)
data.append(36)
# Write an array to the file.
data.tofile(file)
file.close()

